In [1]:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
df = pd.read_csv('time_data/walmart_stock.csv',
index_col = 'Date')
df.index = pd.to_datetime(df.index)
In [3]:
df.head()
Out[3]:
In [4]:
df.tail()
Out[4]:
In [5]:
df.shift(1).head()
Out[5]:
In [6]:
# You will lose that last piece of data that no longer has an index!
df.shift(1).tail()
Out[6]:
In [7]:
df.shift(-1).head()
Out[7]:
In [8]:
df.shift(-1).tail()
Out[8]:
In [9]:
# Shift everything forward one month
df.tshift(periods = 1,
freq = 'M').head()
Out[9]:
That is it for now!